package stream;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/*
1.Stream流操作，不会改变数据源
2.Stream收集操作
    xxx.collect(Collectors.toList).var
    xxx.collect(Collectors.toSet).var
    xxx.collect(Collectors.toMap).var，见下一节


 */
public class StreamDemo4 {
    public static void main(String[] args) {
        List<Integer> list1 = Stream.of(1, 2, 3, 4, 5, 6, 7, 8).filter(s -> s % 2 == 0).collect(Collectors.toList());
        System.out.println(list1);

        //set会去重
        Set<Integer> list2 = Stream.of(1, 2, 3, 4, 5, 6, 7, 8,8,8).filter(s -> s % 2 == 0).collect(Collectors.toSet());
        System.out.println(list2);

    }
}
